import request from '@/config/axios'

// 广告数据汇总 VO
export interface CampaignGrandTotalsVO {
  id: number // id
  date: Date // 日期
  granularity: number // 粒度
  impressions: number // 总展示次数
  taps: number // 总点击次数
  installs: number // 总安装次数
  newDownloads: number // 总新安装
  reDownloads: number // 总重复安装
  latOnInstalls: number // LAT开安装次数
  latOffInstalls: number // LAT关安装次数
  ttr: number // 总点击率
  avgCpaAmount: number // 次转化费用
  avgCpaCurrency: string // 转化货币
  avgCptAmount: number // 次点击付费
  avgCptCurrency: string // 点击货币
  avgCpmAmount: number // 千次展示付费
  avgCpmCurrency: string // 展示货币
  localSpendAmount: number // 总支出金额
  localSpendCurrency: string // 总支出货币
  conversionRate: number // 总转化率
}

// 广告数据汇总 API
export const CampaignGrandTotalsApi = {
  // 查询广告数据汇总分页
  getCampaignGrandTotalsPage: async (params: any) => {
    return await request.get({ url: `/asasc/campaign-grand-totals/page`, params })
  },

  // 查询广告数据汇总详情
  getCampaignGrandTotals: async (id: number) => {
    return await request.get({ url: `/asasc/campaign-grand-totals/get?id=` + id })
  },

  // 新增广告数据汇总
  createCampaignGrandTotals: async (data: CampaignGrandTotalsVO) => {
    return await request.post({ url: `/asasc/campaign-grand-totals/create`, data })
  },

  // 修改广告数据汇总
  updateCampaignGrandTotals: async (data: CampaignGrandTotalsVO) => {
    return await request.put({ url: `/asasc/campaign-grand-totals/update`, data })
  },

  // 删除广告数据汇总
  deleteCampaignGrandTotals: async (id: number) => {
    return await request.delete({ url: `/asasc/campaign-grand-totals/delete?id=` + id })
  },

  // 导出广告数据汇总 Excel
  exportCampaignGrandTotals: async (params) => {
    return await request.download({ url: `/asasc/campaign-grand-totals/export-excel`, params })
  }
}
